<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // class Star {
        //     constructor(uname, age) {
        //         this.uname = uname;
        //         this.age = age;
        //     }
        // }
        // var ldh = new Star('刘德华', 18);
        // console.log(ldh);

        class Father {
            constructor(x, y) { //构造函数
                this.x = x;
                this.y = y;
            }
            sum() {
                console.log(this.x + this.y);
            }
        }
        class Son extends Father { //子类继承父类
            constructor(x, y) {
                super(x, y); //调用父类构造函数
                this.x = x;
                this.y = y;
            }
            sub() {
                console.log(this.x - this.y);
            }
        }
        var son = new Son(3, 2);
        son.sum();
        son.sub();
    </script>
</body>

</html>